﻿$(function () {

    $('#HostsDialog').dialog({
        autoOpen: false,
        width: 400,
        height: 400,
        resizable: false,
        modal: true,
        buttons: {
            "Submit": function () {
                $("#submitHosts").submit();
            },
            "Cancel": function () {
                $(this).dialog("close");
            }
        }
    });

    $("#Host").focus(function () {
        var dialogDiv = $('#HostsDialog');
        var viewUrl = "/Filters/OpenHostsDialog";
        $.get(viewUrl, function (data) {
            dialogDiv.html(data);
            var $form = $("#submitHosts");
            dialogDiv.dialog('open');
        });

        return false;
    });

});

function hostsFormSubmitted(data) {
    if (data.Success == true) {
        $("#Host").val(data.Object.toString());
        $('#HostsDialog').dialog('close');
    }
}